﻿using System;

namespace School
{
    public struct ExamGrade
    {
        const double MIN_GRADE = 2;
        const double MAX_GRADE = 6;

        private Exam exam;
        private double grade;

        public Exam Exam
        {
            get
            {
                return exam;
            }
            set
            {
                exam = value;
            }
        }

        public double Grade
        {
            get
            {
                return grade;
            }
            set
            {
                if (value < MIN_GRADE || value > MAX_GRADE)
                {
                    string exceptionMessage = string.Format("{0} is not a valid grade. " +
                        "The grade must be in the range {1} to {2}.", value, MIN_GRADE, MAX_GRADE);
                    throw new ArgumentOutOfRangeException(exceptionMessage);
                }
                grade = value;
            }
        }
    }
}
